package com.earthchen.decoder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

/**
 * 字节 int转码器
 *
 * @author: EarthChen
 * @date: 2018/05/02
 */
public class ToIntegerDecoder extends ByteToMessageDecoder {

    @Override
    public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        if (in.readableBytes() >= 4) {
            System.out.println("4444444444" + in.readInt());
            out.add(in.readInt());
        }
    }
}
